/**
 * Copyright 2010 Mark Wyszomierski
 */
package com.ruiyi.json.parser;

import org.json.JSONException;
import org.json.JSONObject;

import com.ruiyi.baseparser.AbstractParser;
import com.ruiyi.json.Json_City;
import com.ruiyi.util.LogUtil;


/**
 * @date July 13, 2010
 * @author Mark Wyszomierski (markww@gmail.com)
 * 
 */
public class CityParser extends AbstractParser<Json_City> {

	private static final String TAG = null;

	@Override
	public Json_City parse(JSONObject json) throws JSONException {

		if (RuiyiUtil.isResultPackage(json)) {
			return null;
		}

		Json_City obj = new Json_City();
		if (json.has("id")) {
			obj.setId(json.getLong("id"));
		}
		if (json.has("name")) {
			obj.setName(json.getString("name"));
		}
		if (json.has("childnum")) {
			obj.setChildNums(json.getInt("childnum"));
		}
		LogUtil.e(TAG, obj.toString());
		return obj;
	}
}